<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let str = "name=12 3";
        // 编码：不转义特殊字符
        let str2 = encodeURI(str);
        console.log("Str2 = ",str2);

        // 编码：转义特殊字符
        let str3 = encodeURIComponent(str);
        console.log("Str3 = ",str3);

        str = decodeURI(str2);
        console.log("str = ",str);

        str = decodeURIComponent(str3);
        console.log("str = ",str);

    </script>
</body>
</html>